package com.tcy.bigevent.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.tcy.bigevent.anno.State;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.groups.Default;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import java.time.LocalDateTime;

/**
 * 文章实体类
 */
@Data
public class Article {
    @NotNull(groups = Article.Update.class)
    private Integer id;               // 文章ID
    @NotEmpty
    @Pattern(regexp ="^\\S{1,10}$")
    private String title;            // 文章标题
    @NotEmpty
    private String content;          // 文章内容
    @NotEmpty
    @URL
    private String coverImg;         // 封面图片URL
    @State
    private String state;            // 文章状态：已发布/草稿
    @NotNull
    private Integer categoryId;      // 分类ID
    private Integer createUser;      // 创建人ID
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;// 创建时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime updateTime;// 更新时间

    public interface Add extends Default {}
    public interface Update extends Default {}
}